#include "Custom_QGraphicsScene.h"

CustomGraphicsView::CustomGraphicsView(QWidget* parent) : QGraphicsView(parent)
    {
        setDragMode(ScrollHandDrag);
        setTransformationAnchor(AnchorUnderMouse);
        setResizeAnchor(AnchorUnderMouse);
    }


    void CustomGraphicsView::wheelEvent(QWheelEvent* event) 
    {
        // 检查是否按住 Ctrl 键
        if (event->modifiers() & Qt::ControlModifier) {
            if (event->angleDelta().y() > 0) {
                scale(1.2, 1.2);  // 放大
            }
            else {
                scale(0.8, 0.8);  // 缩小
            }
            event->accept();
        }
        else {
            // 如果没有按 Ctrl，则正常滚动
            QGraphicsView::wheelEvent(event);
        }
    }